package br.com.rpinfo.helpdesk.util;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {

  private static final SessionFactory factory;
  private static final ServiceRegistry registry;

  static {
    Configuration cfg = new Configuration();
    cfg.configure("hibernate.cfg.xml");
    registry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
    factory = cfg.buildSessionFactory(registry);
  }

  public static SessionFactory getSessionFactory() {
    return factory;
  }

}
